package com.lingx.web.api.impl;

import java.util.Map;

import com.lingx.web.api.IApi;

public abstract class AbstractApi implements IApi {

	public int before(Map<String, Object> params) {
		return 0;
	}
	public String getGroupName() {
		return "公共接口";
	}
	public boolean checkIsNullView(Map<String, Object> param,String key,String view,Map<String,Object> ret){
		boolean b=(param.get(key)==null||"".equals(param.get(key).toString()));
		if(b){
			ret.put("code",-1);
			ret.put("message",String.format("%s不可为空", (view==null||"".equals(view))?key:view));
		}
		return b;
	}
	
	public boolean checkIsNull(Map<String, Object> param,String key,Map<String,Object> ret){
		return this.checkIsNullView(param, key, key, ret);
	}
	public boolean checkIsNull(Map<String, Object> param,Map<String,Object> ret,String... keys) {
		for (String key : keys) {
			if (this.checkIsNullView(param, key, key, ret)) {
				return true;
			}
		}
		return false;
	}
	public Map<String,Object> getRetMap(){
		return getRetMap(1,"SUCCESS");
	}
	public Map<String,Object> getRetMap(int code,String message){
		return IApi.getRetMap(code, message);
	}
	public String getParamString(Map<String,Object> params,String key,String defaultValue) {
		return IApi.getParamString(params, key, defaultValue);
	}
	public boolean isLog() {
		return false;
	}
}
